package common;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ConnectionDAO {

	static Logger lgr = Logger.getLogger(ConnectionDAO.class.getName());
	private static Connection con = null;

    static String url = "jdbc:mysql://localhost:3306/sklep?useUnicode=true&characterEncoding=utf8";
    static String user = "root";
    static String password = "";
    
    public static Connection getConnection(){
    	if(con == null){
    		 try {
 			  	try {
 					Class.forName("com.mysql.jdbc.Driver");
 				} catch (ClassNotFoundException e) {
 					// TODO Auto-generated catch block
 					e.printStackTrace();
 				}
 	            con = DriverManager.getConnection(url, user, password);
 	        } catch (SQLException ex) {
 	           
 	            lgr.log(Level.SEVERE, ex.getMessage(), ex);

 	        } finally {
 	        }
    	}
    	
    	return con;
    		
    }
    
    
	
}
